﻿
Public Class QuanLyXe
    Public Sub TiepNhanXe(ByVal TenChuXe As String, ByVal BienSo As String, ByVal TenHieuXe As String, ByVal DienThoai As String, ByVal DiaChi As String)
        Dim xeVal As New Xe
        Dim khVal1 As New KhachHang
        Dim x As New HieuXe
        'x.TenHieuXe = TenChuXe
        'khVal.MaKhachHang = 123
        khVal1.TenKhachHang = TenChuXe
        khVal1.DienThoai = DienThoai
        khVal1.DiaChi = DiaChi
        'Dim kh As String = khVal.DiaChi
        Dim context As New DataQuanLyGaraDataContext

        context.KhachHangs.InsertOnSubmit(khVal1)
        context.SubmitChanges()

        'xeVal.BienSo = BienSo
        ''xeVal.MaHieuXe = MaHieuXe
        'xeVal.TienNo = 0
        'xeVal.NgayTiepNhan = DateTime.Now
        ''Dim Maxid = (From vd In context.KhachHangs Order By (vd.MaKhachHang)
        ''           Select vd.MaKhachHang).Last()
        'xeVal.MaKhachHang = Maxid
        ''Dim maHieuXe = (From mh In context.HieuXes Where mh.TenHieuXe = TenHieuXe Select mh).Last()
        'xeVal.MaHieuXe = maHieuXe.MaHieuXe

        'context.Xes.InsertOnSubmit(xeVal)

    End Sub

    Public Function LayDanhSach() As IList
        Dim context As New DataQuanLyGaraDataContext
        Dim kq = (From f In context.Xes _
                                       Join tr In context.HieuXes On tr.MaHieuXe Equals f.MaHieuXe
                                       Join kh In context.KhachHangs On kh.MaKhachHang Equals f.MaKhachHang
                                       Select f.BienSo, f.KhachHang, f.HieuXe, f.TienNo, f.NgayTiepNhan)
        Return kq.ToList
    End Function
End Class
